package edu.sctu.renpingan.day20150518;

import java.util.Arrays;

/**
 * Created by user18 on 2015/5/18.
 */
public class TextOne extends TextMore {

    public TextOne(Teacher[] teaCher) {
        super(teaCher);
    }

    public void getTercherInfo() {
        for (int i = 0; i < teaCher.length; i++) {
            System.out.println(teaCher[i].number + "  " + teaCher[i].age + "  " + teaCher[i].name + "  " + teaCher[i].object + "  " + teaCher[i].sex + "  " + teaCher[i].work + "  ");
        }
    }

    public void getStudent(int code, Student[] student) {


        for (int i = 0; i < student.length; i++) {
            if (student[i] != null && student[i].grade > code) {

                System.out.println("成绩大于code的学生: " + student[i].name + "  " + student[i].grade + "   ");
            }
        }

    }

    public void getCode(Teacher[] teacher) {
        System.out.println("职称为教授的老师：" + teacher[0].name);
        System.out.println("职称为教授的老师的学生：");
        for (int i = 0; i < teacher[0].student.length; i++) {

            System.out.println(teacher[0].student[i].name);
        }
    }

    public Student[] getCourse() {

        int teaCher0lenth = teaCher[0].student.length;
        int teaCher1lenth = teaCher[1].student.length;
        Student[] students1 = new Student[teaCher0lenth+teaCher1lenth];
        teaCher[0].student = Arrays.copyOf(teaCher[0].student, teaCher0lenth + teaCher1lenth);
        System.arraycopy(teaCher[1].student, 0, teaCher[0].student, teaCher0lenth, teaCher1lenth);
        System.out.println("学生选课情况：");
        for (int j = 0; j < teaCher[0].student.length; j++) {
            System.out.println(teaCher[0].student[j].name+" " + teaCher[0].student[j].textcours.course1+" " + teaCher[0].student[j].textcours.course2);
        }
        students1 =teaCher[0].student;
        return students1;
    }
    Student[] students;
    public void course(Student[] students) {
        this.students = students;
        int chinesetimes = 0;
        int mathtimes = 0;
        int physicstimes = 0;
        System.out.println("选语文的学生：");
        for (int i = 0; i < students.length; i++) {
            if (students[i].textcours.course1.equals("语文") || students[i].textcours.course2.equals("语文")) {
                chinesetimes++;
                System.out.println(students[i].name);
            }
        }
        System.out.println("选数学的学生：");
        for (int i = 0; i < students.length; i++) {
            if (students[i].textcours.course1.equals("数学") || students[i].textcours.course2.equals("数学")) {
                mathtimes++;
                System.out.println(students[i].name);
            }
        }
        System.out.println("选物理的学生：");
        for (int i = 0; i < students.length; i++) {
            if (students[i].textcours.course1.equals("物理") || students[i].textcours.course2.equals("物理")) {
                physicstimes++;
                System.out.println(students[i].name);
            }
        }
           if(chinesetimes>mathtimes && chinesetimes>physicstimes){
               System.out.println("被选次数最多的为语文");
           }

    }

}




